﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Timers;

namespace HandingExpression
{
    class Program
    {
        static void Main(string[] args)
        {
            //int i = 0;
            //int val = 10 / i;
            string filePath = "example.txt";

            try
            {
                if (File.Exists(filePath))
                {
                    string content = File.ReadAllText(filePath);
                }
                else
                {
                    Console.WriteLine($"no exist file path {filePath}");

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                Console.WriteLine("finallly");
            }

            Timer myTimer = new Timer(1000);
            myTimer.Enabled = true;
            myTimer.Elapsed += MyTimer_Elapsed;
            myTimer.Elapsed += MyTimer_Elapsed1;
            Console.WriteLine("input any key to about read outPut.");
            Console.ReadLine();
            myTimer.Elapsed -= MyTimer_Elapsed1;

            Console.ReadKey();
        }

        private static void MyTimer_Elapsed1(object sender, ElapsedEventArgs e)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine($"elapsed1 time :{e.SignalTime}");
        }

        private static void MyTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"当前时间:{e.SignalTime}");
        }
    }
}
